Referencing multiple primary keys from a single table.

Поиск
Список
Период
Сортировка
От Daniel Staal
Тема Referencing multiple primary keys from a single table.
Дата
Msg-id 26865494.1064248451@[192.168.1.52]
обсуждение исходный текст
Ответы Re: Referencing multiple primary keys from a single table.  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Re: Referencing multiple primary keys from a single table.  (Bruno Wolff III <bruno@wolff.to>)
Re: Referencing multiple primary keys from a single table.  (Bruno LEVEQUE <bruno.leveque@libertysurf.fr>)
Список pgsql-novice
What is the best way to reference (use as foreign key) a table with
multiple primary keys?

Here's what I have:
Table1:
field1
field2
field3
...
primary key (field1, field2, field3)

Then I have another table that needs to reference Table1 with a
foreign key.  What I really want to do is:
Table2:
field1 Primary key
field2 references table1
...

But that doesn't work.  I haven't yet tried the option of giving
Table2 all three fields of Table1, partly because I'm not really sure
how to write that...  (I did try linking it to the implicit field
generated when I created Table1.  Didn't work.)  The option I'm sure
would work is shoving all three key fields of Table1 into one field,
but that's a bit messy with the data.  (Though it is doable.)

Is there any really good way to do this that I'm just missing?

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

В списке pgsql-novice по дате отправления:

Предыдущее
От: Bryan Irvine
Дата:
Сообщение: Replication
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Referencing multiple primary keys from a single table.